ALMaSS  1.0
The Animal, Landscape and Man Simulation System
MapErrorMsg Class Reference

#include <maperrormsg.h>

Public Member Functions

void Warn (MapErrorState a_level, std::string a_msg1, std::string a_msg2)
 
void Warn (MapErrorState a_level, std::string a_msg1, int)
 
void Warn (std::string a_msg1, std::string a_msg2)
 
void Warn (std::string a_msg1, double a_num)
 
void WarnAddInfo (MapErrorState a_level, std::string a_add1, std::string a_add2)
 
void WarnAddInfo (MapErrorState a_level, std::string a_add1, double a_num)
 
void SetWarnLevel (MapErrorState a_level)
 
 MapErrorMsg (std::string a_warnfile)
 

Private Attributes

MapErrorState m_level
 
std::string m_warnfile
 

Constructor & Destructor Documentation

◆ MapErrorMsg()

MapErrorMsg::MapErrorMsg ( std::string  a_warnfile)
44 {
45  m_warnfile = a_warnfile;
46 }
std::string m_warnfile
Definition: maperrormsg.h:46

References m_warnfile.

Member Function Documentation

◆ SetWarnLevel()

void MapErrorMsg::SetWarnLevel ( MapErrorState  a_level)
49 {
50  if ( a_level > WARN_BUG && a_level <= WARN_ALL )
51  m_level = a_level;
52  else {
53  m_level = WARN_ALL;
54  Warn( WARN_BUG, "MapErrorMsg::SetWarnLevel(): Illegal error level!", "");
55  exit(1);
56  }
57 }
MapErrorState m_level
Definition: maperrormsg.h:45
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
@ WARN_ALL
Definition: maperrormsg.h:40
@ WARN_BUG
Definition: maperrormsg.h:34

References m_level, Warn(), WARN_ALL, and WARN_BUG.

Referenced by main().

◆ Warn() [1/4]

void MapErrorMsg::Warn ( MapErrorState  a_level,
std::string  a_msg1,
int  a_msg2 
)
84 {
85  FILE * EFile;
86  time_t aclock;
87  tm* newtime;
88  time(&aclock); // Get time in seconds.
89  newtime = localtime(&aclock); // Convert time to struct tm form.
90 
91  // Print local time as a string
92  EFile = fopen(m_warnfile.c_str(), "a+");
93  if (!EFile) {
94  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
95  " for error messages: %s\n", m_warnfile.c_str());
96  exit(1);
97  }
98 
99  fprintf(EFile, "%s Level %d *****\n%s %d\n",
100  asctime(newtime), a_level, a_msg1.c_str(), a_msg2);
101  fflush(EFile);
102  fclose(EFile);
103 }

References m_warnfile.

◆ Warn() [2/4]

void MapErrorMsg::Warn ( MapErrorState  a_level,
std::string  a_msg1,
std::string  a_msg2 
)
62 {
63  FILE * EFile;
64  time_t aclock;
65  tm* newtime;
66  time(&aclock); // Get time in seconds.
67  newtime = localtime(&aclock); // Convert time to struct tm form.
68 
69  // Print local time as a string
70  EFile = fopen(m_warnfile.c_str(), "a+");
71  if (!EFile) {
72  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
73  " for error messages: %s\n", m_warnfile.c_str());
74  exit(1);
75  }
76 
77  fprintf(EFile, "%s Level %d *****\n%s %s\n",
78  asctime(newtime), a_level, a_msg1.c_str(), a_msg2.c_str());
79  fflush(EFile);
80  fclose(EFile);
81 }

References m_warnfile.

Referenced by OptimisingFarm::ActualProfit(), Landscape::AddBeetleBanks(), Partridge_Covey::AddMember(), AlleleFreq::AlleleFreq(), AlleleFreq1616::AlleleFreq1616(), AlleleFreq256_16::AlleleFreq256_16(), AOR_Probe::AOR_Probe(), LE_TypeClass::BackTranslateEleTypes(), LE_TypeClass::BackTranslateVegTypes(), Goose_Population_Manager::BirdsShot(), Goose_Population_Manager::BirdsToShootAtPoly(), Landscape::BorderAdd(), Landscape::BorderNeed(), Landscape::BorderScan(), Skylark_Population_Manager::BreedingPairsOutput(), Skylark_Population_Manager::BreedingSuccessProbeOutput(), Skylark_Female::CalcFoodTime(), RasterMap::CellReplacementNeighbour(), Landscape::CentroidSpiralOut(), Farm::CheckRotationManagementLoop(), Crop::ChooseNextCrop(), Partridge_Population_Manager::CloseParOutputFiles(), FarmManager::ConnectFarm(), Landscape::ConsolidatePolys(), CoveyManager::CoveyManager(), FarmManager::CreateFarms(), k_factors::CreateInfoDatabaseFile(), CreatePopulationManager(), CropRotation::CropRotation(), Calendar::DayLength(), AnimalFarm::determineMinFodder(), Hunter_Population_Manager::DistributeHunters(), Hunter_Population_Manager::DistributeHuntersByRules(), Hunter_Population_Manager::DoFirst(), Vole_Population_Manager::DoFirst(), RodenticideManager::DoPlaceBait(), FarmManager::DumpFarmrefs(), k_factors::DumpInfoDatabase(), k_factors::DumpInfoDatabase1(), Landscape::DumpMapGraphics(), SkTerritories::DumpMapGraphics(), Landscape::DumpMapInfoByArea(), PesticideMap::DumpPMap(), Configurator::DumpSymbols(), Landscape::DumpTreatCounters(), Partridge_Population_Manager::EvalHabitatQual(), Landscape::EventDump(), Landscape::EventDumpPesticides(), Landscape::EventtypeToString(), Configurator::ExtractString(), probe_data::FileAppendOutput(), OptimisingFarm::Find_neighbour_to_imitate(), FarmManager::FindClosestFarm(), FarmManager::FindClosestFarmOpenness(), FarmManager::FindClosestFarmOpennessProb(), FarmManager::FindClosestFarmOpennessProbNearRoostIsBest(), FarmManager::FindClosestFarmOpennessProbSmallIsBest(), OptimisingFarm::findCropByName(), OptimisingFarm::findCropByName_almass(), FarmManager::FindFarmWithOpenness(), FarmManager::FindFarmWithRandom(), Skylark_Population_Manager::FledgelingProbeOutput(), Landscape::ForceArea(), RasterMap::Get(), DataForOptimisation::Get_farmType(), GeneticMaterial1616::GetAllele(), FarmManager::GetFarmCentroid(), FarmManager::GetFarmPtr(), CropRotation::GetFirstCrop(), CropRotation::GetNextCrop(), FarmManager::GetRenumberedFarmRef(), Landscape::GISASCII_Output(), Partridge_Covey::HabitatEvalPoly(), OptimisingFarm::HandleEvents(), Hunter_Population_Manager::HunterLeaderMessage(), Landscape::IncTreatCounter(), Goose_Population_Manager::InHuntingSeason(), THare_Population_Manager::Init(), TrapLineMap::Init(), MovementMap::Init(), Hunter_Population_Manager::Init(), Partridge_Population_Manager::Init(), Vole_Population_Manager::Init(), RasterMap::Init1(), RasterMap::Init2(), OptimisingFarm::Initialize(), Farm::InitiateManagement(), Landscape::InitOsmiaBeeNesting(), Bembidion_Adult::InternalPesticideHandlingAndResponse(), Newt_Egg::InternalPesticideHandlingAndResponse(), Newt_Larva::InternalPesticideHandlingAndResponse(), Newt_Juvenile::InternalPesticideHandlingAndResponse(), Newt_Male::InternalPesticideHandlingAndResponse(), Newt_Female::InternalPesticideHandlingAndResponse(), Rabbit_Juvenile::InternalPesticideHandlingAndResponse(), Rabbit_Male::InternalPesticideHandlingAndResponse(), Rabbit_Female::InternalPesticideHandlingAndResponse(), Farm::InvIntPartition(), k_factors::k_factors(), Landscape::Landscape(), Farm::LeSwitch(), Rabbit_Population_Manager::LoadWarrenLocations(), OptimisingFarm::Make_rotations(), Farm::Management(), OptimisingFarm::Match_crop_to_field(), Partridge_Covey::MoveCanMove(), Partridge_Covey::MoveDistance(), Partridge_Covey::NestBadArea(), Landscape::NewElement(), Newt_Population_Manager::Newt_Population_Manager(), Bembidion_Pupae::OnFarmEvent(), Vole_JuvenileMale::OnFarmEvent(), Vole_JuvenileFemale::OnFarmEvent(), probe_data::OpenFile(), probe_data::OpenForAppendToFile(), Vole_Population_Manager::OpenSexRatiosProbe(), Skylark_Population_Manager::OpenTheBreedingPairsProbe(), Skylark_Population_Manager::OpenTheBreedingSuccessProbe(), Population_Manager::OpenTheMonthlyRipleysOutputProbe(), Population_Manager::OpenTheReallyBigProbe(), Population_Manager::OpenTheRipleysOutputProbe(), Configurator::ParseCfgLine(), Partridge_Communication::PassMessage(), PollenNectarDevelopmentData::PollenNectarDevelopmentData(), Landscape::PolysDump(), Landscape::PolysRenumber(), Landscape::PolysValidate(), Landscape::PolytypeToString(), SkTerritories::PreFillQualGrid(), FarmManager::PrintOutput(), OptimisingFarm::randomizeCropList(), RasterMap::RasterMap(), VegElement::ReadBugPercentageFile(), FarmManager::ReadCropsData_perFarm_and_Soil_and_Size_almass(), FarmManager::ReadCropsData_perFarmType_almass(), FarmManager::ReadCropsData_perSoilType_almass(), Landscape::ReadPolys2(), Farm::ReadRotation(), Configurator::ReadSymbols(), Farm::RemoveField(), GooseActiveForageLocation::RemoveGeese(), Partridge_Covey::RemoveMember(), Landscape::RemoveSmallPolygons(), Hunter_Population_Manager::RuleSet10Based(), Partridge_Covey::SanityCheck(), CoveyManager::SanityCheck1(), Partridge_Covey::SanityCheck2(), Partridge_Covey::SanityCheck3(), Partridge_Covey::SanityCheck4(), Pesticide::SavePPM(), Rabbit_Population_Manager::SaveWarrenLocations(), CfgFloat::set(), CfgInt::set(), GeneticMaterial1616::SetAllele(), Configurator::SetCfgBool(), Configurator::SetCfgFloat(), Configurator::SetCfgGatekeeper(), Configurator::SetCfgInt(), Configurator::SetCfgStr(), Hunter_Population_Manager::SetHuntingSeason(), Partridge_Covey::SetUncle(), PlantGrowthData::SetVegNum(), SetWarnLevel(), Newt_Female::st_Breed(), Goose_Base::st_ChooseForageLocation(), Skylark_Female::st_Finding_Territory(), Goose_Base::st_Forage(), Skylark_Female::st_Laying(), Skylark_Female::st_MakingNest(), Bembidion_Egg_List::Step(), Bembidion_Larvae::Step(), Bembidion_Adult::Step(), Partridge_Covey::SupplyChickAge(), Partridge_Covey::SupplyDistanceMoved(), Partridge_Covey::SupplyFoodToday(), OptimisingFarm::total(), OptimisingFarm::Translate_crops_to_almass(), FarmManager::TranslateAnimalsCodes(), FarmManager::TranslateCropCodes(), FarmManager::TranslateCropsCodes(), FarmManager::TranslateCropVariablesCodes(), LE_TypeClass::TranslateEleTypes(), FarmManager::TranslateFarmCodes(), FarmManager::TranslateFarmSizeCodes(), FarmManager::TranslateLivestockParametersCodes(), FarmManager::TranslateParametersCodes(), FarmManager::TranslateSoilCodes(), LE_TypeClass::TranslateVegTypes(), Landscape::UnsprayedMarginAdd(), UserDefinedFarm::UserDefinedFarm(), Landscape::VegDump(), PlantGrowthData::VegTypeToCurveNum(), Landscape::VegtypeToString(), Landscape::Warn(), and Weather::Weather().

◆ Warn() [3/4]

void MapErrorMsg::Warn ( std::string  a_msg1,
double  a_num 
)
128 {
129  FILE * EFile;
130  time_t aclock;
131  tm* newtime;
132  time( &aclock ); // Get time in seconds.
133  newtime=localtime( &aclock ); // Convert time to struct tm form.
134  // Print local time as a string.
135 
136  EFile=fopen(m_warnfile.c_str(), "a+" );
137  if ( !EFile ) {
138  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
139  " for error messages: %s\n", m_warnfile.c_str() );
140  exit(1);
141  }
142 
143  fprintf( EFile, "%s *****\n%s %g\n",
144  asctime(newtime), a_msg1.c_str(), a_num );
145  fflush( EFile );
146  fclose( EFile );
147 }

References m_warnfile.

◆ Warn() [4/4]

void MapErrorMsg::Warn ( std::string  a_msg1,
std::string  a_msg2 
)
106 {
107  FILE * EFile;
108  time_t aclock;
109  tm* newtime;
110  time( &aclock ); // Get time in seconds.
111  newtime=localtime( &aclock ); // Convert time to struct tm form.
112  // Print local time as a string.
113 
114  EFile=fopen(m_warnfile.c_str(), "a+" );
115  if ( !EFile ) {
116  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
117  " for error messages: %s\n", m_warnfile.c_str() );
118  exit(1);
119  }
120 
121  fprintf( EFile, "%s *****\n%s %s\n",
122  asctime(newtime), a_msg1.c_str(), a_msg2.c_str() );
123  fflush( EFile );
124  fclose( EFile );
125 }

References m_warnfile.

◆ WarnAddInfo() [1/2]

void MapErrorMsg::WarnAddInfo ( MapErrorState  a_level,
std::string  a_add1,
double  a_num 
)
165 {
166  if (a_level > m_level) return;
167  ofstream *EFile;
168  EFile = new ofstream(m_warnfile.c_str(), ios::app);
169  if (!EFile->is_open()) {
170  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
171  " for error messages: %s\n", m_warnfile.c_str());
172  exit(1);
173  }
174  (*EFile) << a_add1.c_str() << a_num << endl;
175  EFile->close();
176 }

References m_level, and m_warnfile.

◆ WarnAddInfo() [2/2]

void MapErrorMsg::WarnAddInfo ( MapErrorState  a_level,
std::string  a_add1,
std::string  a_add2 
)
150 {
151  FILE * EFile;
152  if (a_level > m_level) return;
153  EFile = fopen(m_warnfile.c_str(), "a+");
154  if (!EFile) {
155  fprintf(stderr, "MapErrorMsg::Warn(): Unable to open file"
156  " for error messages: %s\n", m_warnfile.c_str());
157  exit(1);
158  }
159  fprintf(EFile, "%s%s", a_add1.c_str(), a_add2.c_str());
160  fflush(EFile);
161  fclose(EFile);
162 }

References m_level, and m_warnfile.

Referenced by RasterMap::Get(), RasterMap::Init2(), and Configurator::ShowIdType().

Member Data Documentation

◆ m_level

MapErrorState MapErrorMsg::m_level
private

Referenced by SetWarnLevel(), and WarnAddInfo().

◆ m_warnfile

std::string MapErrorMsg::m_warnfile
private

Referenced by MapErrorMsg(), Warn(), and WarnAddInfo().


The documentation for this class was generated from the following files: